<?php
require 'Admin/Controller/Controller.php ';
require 'Admin/Model/UserModel.php';
class UserController extends Controller{
	function __Construct(){
		parent::__Construct();
		$this->model = new CxModel();
	}
	function index(){
		$data = $this->model->getList();
		$this->assign('list',$data);
		$this->display(); 

	}
	function form(){
		$this->display();
	}
	function add(){
		$data = $_POST;
		$result = $this->model->add($data);
		if($result){
			echo '添加成功 <a href="admin.php?c=cx&m=index">如果没有跳转，请点这里跳转</a>';
   			header("refresh:3;url='admin.php?c=cx&m=index'");
		}
		else{
			echo "添加失败！<br/>";
  			echo "<a href='admin.php?c=cx&m=form'>返回</a>";
		}

	}
	function del(){
		$id = $_GET['id'];
		$result = $this->model->del($id);
		if($result){
			echo '删除成功 <a href="admin.php?c=cx&m=index">如果没有跳转，请点这里跳转</a>';
   			header("refresh:3;url='admin.php?c=cx&m=index'");
		}
		else{
			echo "删除失败！<br/>";
  			echo "<a href='admin.php?c=cx&m=index'>返回</a>";
		}
	}
	//function dels(){}
	function mod(){
		$id = $_GET['id'];
		$result = $this->model->getOneByID($id);
		$this->assign('one',$result);
		$this->display(); 
	}
	function update(){
		$data = $_POST;
		$result = $this->model->update($data);
		if($result){
			echo '更新成功 <a href="admin.php?c=cx&m=index">如果没有跳转，请点这里跳转</a>';
   			header("refresh:3;url='admin.php?c=cx&m=index'");
		}
		else{
			echo "更新失败！<br/>";
  			echo "<a href='admin.php?c=cx&m=mod&id=".$data['id']."'>返回</a>";
		}
	}
/*	function search(){

	}*/
}
?>